package buzzTest;

import javax.sound.midi.*;
import javax.sound.midi.MidiDevice.Info;

public class BuzzTest2 {
	private static Sequencer sequencer;
	
	public static void main(String args[]){
		try{
			Info[] infos = MidiSystem.getMidiDeviceInfo();
			Info info = null;
			for (Info currInfo : infos)
			{
				if(currInfo.toString().contains("Out") && 
						currInfo.toString().contains("MIDI Yoke:") &&
						currInfo.toString().contains("1"))
				{
					info = currInfo;
					System.out.println("Selected: " + info.toString());
					break;
				}
				System.out.println(currInfo);
			}
			
			System.out.println("Info: " + info.toString());
			MidiDevice MY1device = MidiSystem.getMidiDevice(info);
			System.out.println("Selected: " + info);
			MY1device.open();
			
			ShortMessage msg = new ShortMessage();
			msg.setMessage(ShortMessage.CONTROL_CHANGE, 1, 1, 10);
			
			Receiver rec = MY1device.getReceiver();
			
			ShortMessage msg2 = new ShortMessage();
			msg2.setMessage(ShortMessage.CONTROL_CHANGE, 1, 1, 127);
			
			while (1 == 1)
			{
				rec.send(msg, 0);
				System.out.println("Sent 10");
				Thread.sleep(2000);
				rec.send(msg2, 0);
				System.out.println("Sent 127");
				Thread.sleep(1500);
			}
			
			
		} catch (Exception e){
			
		}
	}
}
